package cn.cs.service;

import cn.cs.mapper.ClientRepRelMapper;
import cn.cs.mapper.ClientUserMapper;
import cn.cs.pojo.ClientRepRel;
import cn.cs.pojo.ClientUser;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@RestController
public class ClientUserService {

    //@Autowired
    @Resource
    private ClientUserMapper clientUserMapper;

    @Resource
    private ClientRepRelMapper clientRepRelMapper;

    @RequestMapping(value = "/getClientUserByPhone", method = RequestMethod.POST)
    public ClientUser getClientUserByPhone(@RequestParam("phone") String phone) throws Exception {
        return clientUserMapper.getClientUserByPhone(phone);
    }

    @RequestMapping(value = "/getClientUserByLikePhone", method = RequestMethod.POST)
    public List<ClientUser> getClientUserByLikePhone(@RequestParam("phone") String phone)throws Exception{
        return clientUserMapper.getClientUserByLikePhone(phone);
    }

    @RequestMapping(value = "/getClientUserByOpenIdAccountNull", method = RequestMethod.POST)
    public ClientUser getClientUserByOpenIdAccountNull(@RequestParam("openId") String openId) throws Exception {
        return clientUserMapper.getClientUserByOpenIdAccountNull(openId);
    }

    @RequestMapping(value = "/getClientUserByOpenId", method = RequestMethod.POST)
    public ClientUser getClientUserByOpenId(@RequestParam("openId") String openId) throws Exception{
        return clientUserMapper.getClientUserByOpenId(openId);
    }

    @RequestMapping(value = "/updateClientUserByOpenId", method = RequestMethod.POST)
    public Integer updateClientUserByOpenId(@RequestBody ClientUser clientUser) throws Exception{
        return clientUserMapper.updateClientUserByOpenId(clientUser);
    }

    @RequestMapping(value = "/updateClientUsersByOpenId", method = RequestMethod.POST)
    public Integer updateClientUsersByOpenId(@RequestBody ClientUser clientUser) throws Exception{
        return clientUserMapper.updateClientUsersByOpenId(clientUser);
    }

    @RequestMapping(value = "/getClientUserByAccount", method = RequestMethod.POST)
    public ClientUser getClientUserByAccount(@RequestParam("account") String account) throws Exception{
        return clientUserMapper.getClientUserByAccount(account);
    }

    @RequestMapping(value = "/updateClientUser", method = RequestMethod.POST)
    public Integer updateClientUser(@RequestBody ClientUser clientUser) throws Exception{
        return clientUserMapper.updateClientUser(clientUser);
    }

    @RequestMapping(value = "/insertClientRepRel", method = RequestMethod.POST)
    public Integer insertClientRepRel(@RequestBody ClientRepRel clientRepRel) throws Exception{
        return clientRepRelMapper.insertClientRepRel(clientRepRel);
    }

    @RequestMapping(value = "/updateClientRepRel", method = RequestMethod.POST)
    public Integer updateClientRepRel(@RequestBody ClientRepRel clientRepRel) throws Exception{
        return clientRepRelMapper.updateClientRepRel(clientRepRel);
    }

    @RequestMapping(value = "/getClientUserById", method = RequestMethod.POST)
    public ClientUser getClientUserById(@RequestParam("id") String id) throws Exception{
        return clientUserMapper.getClientUserById(id);
    }

    @RequestMapping(value = "/getClientUserListByMap", method = RequestMethod.POST)
    public List<ClientUser> getClientUserListByMap(@RequestBody Map<String, Object> param) throws Exception{
        return clientUserMapper.getClientUserListByMap(param);
    }

    @RequestMapping(value = "/getClientUserCountByMap", method = RequestMethod.POST)
    public Integer getClientUserCountByMap(@RequestBody Map<String, Object> param) throws Exception{
        return clientUserMapper.getClientUserCountByMap(param);
    }

    @RequestMapping(value = "/getWxVersionCode", method = RequestMethod.POST)
    public Map<String, Object> getWxVersionCode() throws Exception{
        return clientUserMapper.getWxVersionCode();
    }

    @RequestMapping(value = "/setWxVersionCode", method = RequestMethod.POST)
    public Integer setWxVersionCode(@RequestParam("versionCode") String versionCode) throws Exception{
        return clientUserMapper.setWxVersionCode(versionCode);
    }

    @RequestMapping(value = "/getUserByRepUserId", method = RequestMethod.POST)
    public List<Map<String, Object>> getUserByRepUserId(@RequestParam("rep_user_id") String rep_user_id) throws Exception{
        return clientUserMapper.getUserByRepUserId(rep_user_id);
    }

    @RequestMapping(value = "/saveUserScoreHistory", method = RequestMethod.POST)
    public Integer saveUserScoreHistory(@RequestBody Map<String, Object> map)throws Exception{
        return clientUserMapper.saveUserScoreHistory(map);
    }

    @RequestMapping(value = "/getUserScoreHistoryByUserId", method = RequestMethod.POST)
    public List<Map<String, Object>> getUserScoreHistoryByUserId(@RequestParam("userId") String userId)throws Exception{
        return clientUserMapper.getUserScoreHistoryByUserId(userId);
    }

    @RequestMapping(value = "/getClientRepRelListByMap", method = RequestMethod.POST)
    public List<ClientRepRel>	getClientRepRelListByMap(@RequestBody Map<String, Object> param)throws Exception{
        return clientRepRelMapper.getClientRepRelListByMap(param);
    }
}
